package de.mhus.lib.mandala;

import de.mhus.lib.core.MString;

public class StyleUtil {
	
	public <T extends Component> T pullRight(T item) {
		appendClass(item,"pull-right");
		return item;
	}

	public static <T extends Component> T appendClass(T item, String clazz) {
		String classes = item.getTagAttributes().getStyleClass();
		if (MString.isEmpty(classes))
			item.getTagAttributes().setStyleClass(clazz);
		else {
			if (classes.equals(clazz) || classes.startsWith(clazz + " ") || classes.endsWith(" " + clazz) || classes.indexOf(" " + clazz + " ") > -1) {
				
			} else
				item.getTagAttributes().setStyleClass(classes + " " + clazz);
		}
		return item;
	}

}

